<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加文章</title>
    <bootstrapjs />
    <bootstrapcss />
    <uploads />
    <icheckcss />
    
</head>
<body>
<form class="form-group" action="{:U('Admin/Article/add')}" method="post" enctype="multipart/form-data">
    <table class="table table-bordered table-striped table-hover table-condensed">
        <tr>
            <th width="80px">所属分类</th>
            <td>
                <select class="form-control modal-sm" name="cid">
                    <foreach name="allCategory" item="v">
                        <option value="{$v['cid']}">{$v['_name']}</option>
                    </foreach>
                </select>
            </td>
        </tr>
        <tr>
            <th>标题</th>
            <td>
                <input class="form-control modal-sm" type="text" name="title">
            </td>
        </tr>
        <tr>
            <th>作者</th>
            <td>
                <input class="form-control modal-sm" type="text" name="author" value="{$Think.config.AUTHOR}">
            </td>
        </tr>
        <tr>
            <th>标签</th>
            <td>
                <foreach name="allTag" item="v">
                    <span class="inputword">{$v['tname']}</span>
                    <input class="icheck" type="checkbox" name="tids[]" value="{$v['tid']}">
                    &emsp;
                </foreach>
            </td>
        </tr>
        <tr>
            <th>关键词</th>
            <td>
                <input class="form-control modal-sm" placeholder="多个关键词用顿号分隔" type="text" name="keywords">
            </td>
        </tr>
        <tr>
            <th>描述</th>
            <td>
                <textarea class="form-control modal-sm" name="description" rows="7" placeholder="可以不填，如不填；则截取文章内容前300字为描述"></textarea>
            </td>
        </tr>
        <tr>
        	<th>缩略图</th>
        	<td>
        		<div lab="uploadFile">
					<!-- file表单 -->
				    <input id="ff" type="file" multiple="true" style="display: inline-block;">
				    <span style="display: inline-block;">类型: *.jpg,*.png 大小: 2000KB 数量: 1</span>
				    <script type="text/javascript">
				        $(function() {
				            $('#ff').uploadify({
				               'formData'     : {
				               		//POST数据
				                    '<?php echo session_name();?>' : '<?php echo session_id();?>',
				                },
				                'fileTypeExts' : '*.jpg;*.png',
				                'swf'      : '__PUBLIC__/static/uploadify/uploadify.swf',
				                'uploader' : '{:U('upload')}',//指定服务器上传的方法
				                'buttonText':'选择文件',
				                'fileSizeLimit' : '2000KB',
				                'uploadLimit' : 1,//上传文件数
				                'width':65,
				                'height':25,
				                'successTimeout':10,//等待服务器响应时间
				                'removeTimeout' : 0.2,//成功显示时间
				                'onUploadSuccess' : function(file, data, response) {
				                    //把php返回的数据转为json
				                    data=$.parseJSON(data);
				                    //获得图片地址
				                    var imageUrl = '__ROOT__/Tmps/'+data.savepath+data.savename;
				                    var imageAddress = './Tmps/'+data.savepath+data.savename;
				                    var li="<li>";
				                    li += "<img src='"+imageUrl+"'/>";
				                    li += "<input type='hidden' name='thumb' value='"+imageAddress+"'/><a href='javascript:;' id='self-close'>X</a>";
				                    li += "</li>";
				                    $("#uploadList ul").prepend(li);
				                }
				            });
				
							//关闭图片
				            var i = 1;
				            $(document).on('click','#self-close',function(){
				                $(this).parent('li').remove();
				                i++;
				                $('#ff').uploadify('settings','uploadLimit',i);
				            })
				        });
				    </script>
				    <div id="uploadList">
				        <ul>
							
				        </ul>
				    </div>
				    <style type="text/css">
				    	#uploadList ul li img{
				    		width: 175px;
				    		height: 120px;
				    	}
				    </style>
				</div>
        	</td>
        </tr>
        <tr>
            <th>内容</th>
            <td>
                <ueditor name="content" />
            </td>
        </tr>
        <tr>
            <th>是否原创</th>
            <td>
                <span class="inputword">是</span>
                <input class="icheck" type="radio" name="is_original" value="1" checked="checked">
                &emsp;
                <span class="inputword">否</span>
                <input class="icheck" type="radio" name="is_original" value="0">
            </td>
        </tr>
        <tr>
            <th>是否置顶</th>
            <td>
                <span class="inputword">是</span>
                <input class="icheck" type="radio" name="is_top" value="1">
                &emsp;
                <span class="inputword">否</span>
                <input class="icheck" type="radio" name="is_top" value="0" checked="checked">
            </td>
        </tr>
        <tr>
            <th>是否显示</th>
            <td>
                <span class="inputword">是</span>
                <input class="icheck" type="radio" name="is_show" value="1" checked="checked">
                &emsp;
                <span class="inputword">否</span>
                <input class="icheck" type="radio" name="is_show" value="0">
            </td>
        </tr>
        <tr>
            <th></th>
            <td>
                <input class="btn btn-success" type="submit" value="发表">
            </td>
        </tr>
    </table>
</form>

<icheckjs />
</body>
</html>
